package com.jiale.ojsystem.judge.codesandbox;

import com.jiale.ojsystem.judge.codesandbox.impl.ExampleCodeSandBox;
import com.jiale.ojsystem.judge.codesandbox.impl.RemoteCodeSandBox;
import com.jiale.ojsystem.judge.codesandbox.impl.ThirdPartyCodeSandBox;

/**
 * 代码沙箱工厂模式
 */
public class CodeSandBoxFactory {
    /**
     * 通过传入的类型生成不同的执行代码模式
     *
     * @param type
     * @return
     */
    public CodeSandBox doExecute(String type) {
        switch (type) {
            case "example":
                return new ExampleCodeSandBox();
            case "remote":
                return new RemoteCodeSandBox();
            case "thirdParty":
                return new ThirdPartyCodeSandBox();
            default:
                return new ExampleCodeSandBox();
        }
    }
}
